<!doctype html>
<html>

	<head>
		<meta charset="UTF-8">
		<title></title>
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<link href="css/mui.min.css" rel="stylesheet" />
		<link href="css/showloading.css" rel="stylesheet" />
	</head>

	<body>
		<header id="header" class="mui-bar mui-bar-nav" style="background: #B01D29;text-align: center;">
			<img src="img/back.png" class=" tp-back mui-icon  mui-icon-left-nav mui-pull-left" style="height: 40px;width: 30px;"></img>
			<a class="mui-title " style="color: white;font: bold;font-size:20px ; ">完善信息</a>
		</header>
		<div class="mui-content">

			<div class="mui-card">
				<div class="mui-card-content" style="margin-top:20px;margin-bottom:20px;">
					<h4 style="margin-left:30px;margin-bottom:10px">完善身份证号码：</h4>
					<div class="mui-input-row" style="margin-left:20px;margin-Right:20px">

						<input type="text" id="cardno" class="mui-input-clear" placeholder="请输入身份证号码">
					</div>
					<div class="mui-button-row">
						<button id="submit" type="button" class="mui-btn mui-btn-primary" onclick="return false;">确认</button>&nbsp;&nbsp;
						<button id="cancle" type="button" class="mui-btn mui-btn-danger" style="margin-left:50px;" onclick="return false;">取消</button>
					</div>
					<p style="margin-left: 20px;margin-top: 10px;">ps：获取饭卡信息需要身份证号</p>
				</div>
			</div>

		</div>

		<script src="js/mui.min.js"></script>
		<script src="js/jquery-3.2.1.min.js"></script>
		<script src="js/showloading.js"></script>
		<script src="js/common.js"></script>
		<script src="js/checkid.js"></script>
		<script type="text/javascript">
			mui.init();

			function goHistory() {
				var u = navigator.userAgent,
					app = navigator.appVersion;
				var isAndroid = u.indexOf('Android') > -1 || u.indexOf('Linux') > -1; //android终端或者uc浏览器
				var isIOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/); //ios终端
				if(isAndroid) {
					console.log('android');
					window.app.back();
				} else if(isIOS) {
					console.log('ios');
					window.webkit.messageHandlers.GoBack.postMessage(null);
				}
			}
			$(".tp-back").on("click", function() {

				goHistory();
			});


			var userid = localStorage.getItem("userid");;

			console.log("idcard-userid" + userid);
			var idcard = "";
			mui(".mui-button-row").on('tap', '#submit', function() {
				console.log($("#cardno").val().toString());
				idcard = $("#cardno").val().toString();
				if(checkCardId($("#cardno").val().toString())) {
					mui.showLoading("正在加载..", "div");
					mui.ajax(oahost + 'oa/editStaff', {
						data: {
							id: userid,
							idCard: idcard
						},
						dataType: 'json', //服务器返回json格式数据
						type: 'post', //HTTP请求类型
						timeout: 10000, //超时时间设置为10秒；
						success: function(data) {
							if(data.success == true) {
								mui.toast("提交成功");
								//跳转到商城页面
								window.location.href = "index.html";
							} else {
								mui.toast("提交失败")
							}
							mui.hideLoading();
						},
						error: function(xhr, type, errorThrown) {
							//异常处理；
							console.log(type);
							mui.hideLoading();
						}
					});
				}
			})

			mui(".mui-button-row").on('tap', '#cancle', function() {
				mui.toast("取消");
			})
		</script>
	</body>

</html>